package com.itheima.service.Impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.itheima.dao.BookDao;
import com.itheima.domain.Book;
import com.itheima.service.BookService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class bookServiceImpl implements BookService {
    @Autowired
    private BookDao bookDao;
    @Override
    public Boolean insert(Book book) {
       return bookDao.insert(book)>0;
    }

    @Override
    public Boolean deleteById(Integer id) {
        return bookDao.deleteById(id)>0;
    }

    @Override
    public Boolean updateById(Book book) {
        return bookDao.updateById(book)>0;
    }

    @Override
    public Book selectById(Integer id) {
        return bookDao.selectById(id);
    }




    @Override
    public List<Book> selectAll() {
        return bookDao.selectList(null);
    }

    @Override
    public IPage<Book> selectByPage(Integer current, Integer pageSize) {
        IPage<Book> page=new Page<>(current,pageSize);
        return bookDao.selectPage(page,null);
    }
}
